package com.belf.web.controller.console;

import com.belf.common.annotation.Log;
import com.belf.common.core.controller.BaseController;
import com.belf.common.core.domain.AjaxResult;
import com.belf.common.core.page.TableDataInfo;
import com.belf.common.enums.BusinessType;
import com.belf.common.utils.poi.ExcelUtil;
import com.belf.console.domain.DataCdcConf;
import com.belf.console.service.IDataCdcConfService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * CDC配置Controller
 * 
 * @author belf
 * @date 2024-06-20
 */
@RestController
@RequestMapping("/console/cdcConf")
public class DataCdcConfController extends BaseController
{
    @Autowired
    private IDataCdcConfService dataCdcConfService;

    /**
     * 查询CDC配置列表
     */
    @PreAuthorize("@ss.hasPermi('console:cdcConf:list')")
    @GetMapping("/list")
    public TableDataInfo list(DataCdcConf dataCdcConf)
    {
        startPage();
        List<DataCdcConf> list = dataCdcConfService.selectDataCdcConfList(dataCdcConf);
        return getDataTable(list);
    }

    /**
     * 导出CDC配置列表
     */
    @PreAuthorize("@ss.hasPermi('console:cdcConf:export')")
    @Log(title = "CDC配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataCdcConf dataCdcConf)
    {
        List<DataCdcConf> list = dataCdcConfService.selectDataCdcConfList(dataCdcConf);
        ExcelUtil<DataCdcConf> util = new ExcelUtil<DataCdcConf>(DataCdcConf.class);
        util.exportExcel(response, list, "CDC配置数据");
    }

    /**
     * 获取CDC配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('console:cdcConf:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dataCdcConfService.selectDataCdcConfById(id));
    }

    /**
     * 新增CDC配置
     */
    @PreAuthorize("@ss.hasPermi('console:cdcConf:add')")
    @Log(title = "CDC配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataCdcConf dataCdcConf)
    {
        return toAjax(dataCdcConfService.insertDataCdcConf(dataCdcConf));
    }

    /**
     * 修改CDC配置
     */
    @PreAuthorize("@ss.hasPermi('console:cdcConf:edit')")
    @Log(title = "CDC配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataCdcConf dataCdcConf)
    {
        return toAjax(dataCdcConfService.updateDataCdcConf(dataCdcConf));
    }

    /**
     * 删除CDC配置
     */
    @PreAuthorize("@ss.hasPermi('console:cdcConf:remove')")
    @Log(title = "CDC配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dataCdcConfService.deleteDataCdcConfByIds(ids));
    }
}
